package pers.kw.goods.enums;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 商品类型
 */
public enum GoodTypeEnum {

    CPU("1001", "cpu", new BigDecimal("2100")),
    GPU("1002", "显卡", new BigDecimal("3900")),
    HARD_DISK("1003", "硬盘", new BigDecimal("560")),
    ;

    private final String goodsNo;

    private final String goodsName;

    private final BigDecimal price;

    public static final List<String> GOOD_TYPE_LIST = new ArrayList<>();

    static {
        GOOD_TYPE_LIST.add(CPU.goodsNo);
        GOOD_TYPE_LIST.add(GPU.goodsNo);
        GOOD_TYPE_LIST.add(HARD_DISK.goodsNo);
    }

    GoodTypeEnum(String goodsNo, String goodsName, BigDecimal price) {
        this.goodsNo = goodsNo;
        this.goodsName = goodsName;
        this.price = price;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public String getGoodsNo() {
        return goodsNo;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public static GoodTypeEnum getGoodTypeByNo(String goodsNo) {
        for (GoodTypeEnum goodTypeEnum : GoodTypeEnum.values()) {
            if (goodTypeEnum.goodsNo.equals(goodsNo)) {
                return goodTypeEnum;
            }
        }
        return null;
    }
}
